<?php
require_once('lib/constants.php');
require_once('lib/menu.php');

function show_link($link, $name)
{
	echo '<li><a href="'.$link.'"';
	if (isset($_SERVER['REDIRECT_URL']) && $link == basename($_SERVER['REDIRECT_URL'])) {
		echo' id="current"';
	}
	echo '>'.$name.'</a></li>';
}

?>

<div id="public_menu_left" class="colonne">
	<?php

	if ($_SESSION['is_connect']) {
	?>
	<ul>
		<li>
			<span style="background:url(images/icons/user.png) no-repeat; text-indent: 25px;">
				Espace adhérent
			</span>
		</li>
		<?php if ($_SESSION['status_code'] == 'ADMIN' || $_SESSION['status_code'] == 'MODERATOR') { ?>
			<li><a href="admin.php">Administration</a></li>
		<?php } ?>
		<li><a href="espace_adh-my_account.html">Mon compte</a></li>
		<li><a href="espace_adh-profils.html">Autres comptes gérés</a></li>
		<li><a href="inscription-inscription-0.html">Autre inscription</a></li>
		<li><br /><a href="deconnexion.html">Se déconnecter</a></li>
	</ul>
	<?php
	}

	$sections = menu_get_list();
	while($section = mysql_fetch_assoc($sections)) {
		if ($section['id'] == ESPACE_ADH_CONNECT /*&& !$_SESSION['is_connect']*/) {
			continue; // ignore espace adhérent connecté si non connecté
		}
		if ($section['id'] == ESPACE_ADH_NOT_CONNECT /*&& $_SESSION['is_connect']*/) {
			continue; // ignore espace adhérent non connecté si connecté
		}
		echo '<ul>';
			echo '<li><span style="background:url(\'images/icons/'.$section['image'].'\') no-repeat; text-indent:25px;">'.$section['name'].'</span></li>';
			$menus = menu_get_list($section['id']);
			while ($menu = mysql_fetch_assoc($menus)) {
				show_link($menu['link'], $menu['name']);
			}
		echo '</ul>';
	}
	require_once('connect.php');
	?>
</div>
